package com.yupi.yuapiclinksdk;

import com.yupi.yuapiclinksdk.client.YuApiClient;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

//通过该注解 将该类标记为一个配置类 告诉spring这一个用于配置的类
@Configuration
//能都读取appplication.yml配置，读取后自动加入属性中
@ConfigurationProperties("yuapi.client")
@Data
//该注解用于自动扫描组件，使得spring 能够自动注册对应的bean
@ComponentScan
public class YuApiClientConfig {
    private String accessKey;

    private String serectKey;

    //创建一个名为“yuApiClient"的bean
    @Bean
    public YuApiClient yuApiClient(){
        //使用ak sk创建一个YuApiClient实例
        return new YuApiClient(accessKey, serectKey);
    }
}
